home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Shareware / Programare / sharp / wwwSharp_setup.exe / {app} / Examples / Data access / DOM / index.hta < prev    next >
Text File  |  2003-12-04  |  3KB  |  112 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4.     <TITLE>www-Sharp.ClrHost data access example</TITLE>
  5.     <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
  6.     <META name="GENERATOR" content="MSHTML 6.00.2800.1264">
  7.     <META http-equiv="MSThemeCompatible" content="Yes">
  8.     <HTA:APPLICATION
  9.         id="appDataAccess"
  10.         APPLICATIONNAME="www-Sharp data access example"
  11.         BORDER="thick"
  12.         BORDERSTYLE="normal"
  13.         CAPTION="yes"
  14.         CONTEXTMENU="yes"
  15.         INNERBORDER="yes"
  16.         MAXIMIZEBUTTON="yes"
  17.         MINIMIZEBUTTON="yes"
  18.         NAVIGABLE="yes"
  19.         SCROLL="no"
  20.         SCROLLFLAT="no"
  21.         SELECTION="yes"
  22.         SHOWINTASKBAR="yes"
  23.         SINGLEINSTANCE="no"
  24.         SYSMENU="yes"
  25.         WINDOWSTATE="normal"></HTA:APPLICATION>
  26.     <OBJECT id="DataAccess" classid="clsid:4CC2B254-F4C7-4F52-881E-C2E10B14E003">
  27.         <PARAM name="AssemblyName" value="DataAccess">
  28.         <PARAM name="TypeName" value="wwwSharp.ClrHost.Examples.DataAccessDOM">
  29.     </OBJECT>
  30.     <LINK href="DataAccess.css" type="text/css" rel="stylesheet">
  31. <SCRIPT language="JScript">
  32. function Initialize()
  33. {
  34.     inputConnStr.value = "Provider=SQLOLEDB;Integrated Security=SSPI;Initial catalog=pubs;";
  35.     textSqlQuery.innerText = "SELECT * FROM authors";
  36.     
  37.     try
  38.     {
  39.         OnBtnShowTablesClick();
  40.     }
  41.     catch(e) {};
  42. }
  43.  
  44. function OnBtnExecuteClick()
  45. {
  46.     try
  47.     {
  48.         DataAccess.ConnectionString = inputConnStr.value;
  49.         DataAccess.SqlQuery = textSqlQuery.innerText;
  50.         DataAccess.ConvertQueryToHtmlTable(tblQuery, btnExecute);
  51.         selectTables.ondblclick = "OnSelectTablesDblClick()";
  52.     }
  53.     catch(e)
  54.     {
  55.         window.alert(e.description);
  56.     }
  57. }
  58.  
  59. function OnBtnStopClick()
  60. {
  61.     DataAccess.StopQuery();
  62. }
  63.  
  64. function OnBtnSelectConnectionClick()
  65. {
  66.     var locator = new ActiveXObject("DataLinks");
  67.     var conn = locator.PromptNew();
  68.     if (conn != null) inputConnStr.value = conn.ConnectionString;
  69.  
  70.     OnBtnShowTablesClick();
  71. }
  72.  
  73. function OnBtnShowTablesClick()
  74. {
  75.     selectTables.innerText = "";
  76.     DataAccess.ConnectionString = inputConnStr.value;
  77.     DataAccess.GetTableNamesForSelect(selectTables);
  78. }
  79.  
  80. function OnSelectTablesDblClick()
  81. {
  82.     var tblName = selectTables.value;
  83.     textSqlQuery.innerText = "SELECT * FROM [" + tblName + "]";
  84. }
  85. </SCRIPT>
  86. </HEAD>
  87. <BODY onload="Initialize()">
  88.     <BUTTON id="btnSelectConnection" onclick="OnBtnSelectConnectionClick()">Connection 
  89.         string:</BUTTON> 
  90.     <INPUT id="inputConnStr" size="75"> 
  91.     <BR>
  92.     <BUTTON id="btnShowTables" onclick="OnBtnShowTablesClick()">Show tables</BUTTON> 
  93.     <BR>
  94.     <LABEL for="textSqlQuery">Sql query:</LABEL> 
  95.     <SELECT id="selectTables" onchange="OnSelectTablesDblClick()"></SELECT> 
  96.     <BR>
  97.     <TEXTAREA id="textSqlQuery" rows="5" cols="50"></TEXTAREA> 
  98.     <BR>
  99.     <BUTTON id="btnExecute" onclick="OnBtnExecuteClick()">Execute query</BUTTON>
  100.     <BUTTON id="btnStop" onclick="OnBtnStopClick()">Stop query</BUTTON>
  101.     <DIV id="divOutput">
  102.         <TABLE id="tblQuery" border="0">
  103.             <TBODY></TBODY>
  104.         </TABLE>
  105.     </DIV>
  106.     <DIV id="divFooter">
  107.         <P id="creator">Created with <A href="http://www-sharp.com/" target="_blank"><STRONG>
  108.             www-Sharp</STRONG></A>.</P>
  109.     </DIV>
  110. </BODY>
  111. </HTML>
  112.